<template>
  <div id="noticeSearch">
    <el-card v-show="props.showSearch" shadow="never">
      <el-form ref="queryFormRef" :inline="true" :model="queryParams">
        <el-form-item label="关键词" prop="keyword">
          <el-input
            v-model="queryParams.keyword"
            clearable
            placeholder="账号/姓名/电话/邮箱"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="创建时间" prop="keyword">
          <el-date-picker
            v-model="queryParams.createTime"
            clearable
            end-placeholder="截止时间"
            range-separator="~"
            start-placeholder="开始时间"
            type="daterange"
            value-format="YYYY-MM-DD"
          />
        </el-form-item>
        <el-form-item>
          <el-button :icon="Search" type="primary" @click="handleQuery">
            搜索
          </el-button>
          <el-button :icon="Refresh" @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
<script lang="ts" setup>
import { defineEmits, defineProps, ref } from "vue";
import { Refresh, Search } from "@element-plus/icons-vue";
import { NoticeQueryParams } from "@/api/models/NoticeQueryDTO";

const props = defineProps<{
  showSearch: boolean;
}>();

const init = {
  createTime: [],
  keyword: "",
};
//查询对象
const queryParams = ref<NoticeQueryParams>({ ...init });

const emit = defineEmits(["handleQuery", "handleReset"]);

//查询方法
function handleQuery() {
  console.log("输入的数字", queryParams.value);
  //调用父级方法
  emit("handleQuery", queryParams.value);
}

//重置方法
function handleReset() {
  queryParams.value = { ...init };
  emit("handleReset");
}
</script>

<style lang="scss" scoped>
#noticeSearch {
  margin-bottom: 10px;
}
</style>
